<div nz-form-item nz-row style="margin-top:20px;margin-bottom: 20px;">
  <div nz-col [nzSpan]="6">
    <button nz-button [nzType]="'primary'" [nzSize]="'small'" col-offset-2 (click)="toBack()">
      <i class="anticon anticon-left"></i>
      <span>返回</span>
    </button>
    <span style="margin-left: 20px;color:red;font-weight: 700">提示：请在返回前保存结果。</span>
  </div>
</div>
<div class="public-random-select">
  <nz-collapseset>
    <nz-collapse [nzTitle]="'筛选主体单位种子数据'" [nzActive]="true" [nzDisabled]="false">
      <nz-collapseset>
        <nz-collapse [nzTitle]="'选取条件'" [nzActive]="true" [nzDisabled]="false">
          <form nz-form [nzLayout]="'inline'">

            <div nz-row>
              <div nz-form-item nz-col [nzSpan]="4">
                <div nz-form-label nz-col [nzSm]="9" [nzXs]="6">
                  <label>梯型</label>
                </div>
                <div nz-form-control nz-col [nzSm]="12" [nzXs]="12">
                  <nz-select [nzMode]="'multiple'" style="width: 200px;" nzAllowClear [nzPlaceHolder]="'请选择'" [(ngModel)]="elevatorTypeParam"
                             [nzShowSearch]="true" name="elevatorTypeParam">
                    <nz-option *ngFor="let option of elevatorType" [nzLabel]="option.typeName"
                               [nzValue]="option.id" [nzDisabled]="option.disabled">
                    </nz-option>
                  </nz-select>
                </div>
              </div>

              <div nz-form-item nz-col [nzSpan]="8">
                <div nz-form-label nz-col [nzSm]="9" [nzXs]="6">
                  <label>梯龄</label>
                </div>
                <div nz-form-control nz-col [nzSm]="12" [nzXs]="12">
                  <nz-select [nzMode]="'multiple'" style="width: 200px;"
                             nzAllowClear [nzPlaceHolder]="'请选择'" [(ngModel)]="elevatorAgeParam" [nzShowSearch]="true"
                             name="elevatorAgeParam">
                    <nz-option [nzLabel]="'10年以下'" [nzValue]="0">
                    </nz-option>
                    <nz-option [nzLabel]="'10~15(年)'" [nzValue]="1">
                    </nz-option>
                    <nz-option [nzLabel]="'15~20(年)'" [nzValue]="2">
                    </nz-option>
                    <nz-option [nzLabel]="'20年以上'" [nzValue]="3">
                    </nz-option>
                  </nz-select>
                </div>
              </div>
              <div nz-form-item nz-col [nzSpan]="4">
                <div nz-form-label nz-col [nzSm]="9" [nzXs]="6">
                  <label>场所</label>
                </div>
                <div nz-form-control nz-col [nzSm]="12" [nzXs]="12">
                  <nz-select [nzMode]="'multiple'" style="width: 200px;"
                             nzAllowClear [nzPlaceHolder]="'请选择'" [(ngModel)]="elevatorPlaceParam" [nzShowSearch]="true"
                             name="elevatorPlaceParam">
                    <!--<nz-option  [nzLabel]="'所有'" [nzValue]="0" ></nz-option>-->
                    <nz-option *ngFor="let option of elevatorPlaces" [nzLabel]="option.value" [nzValue]="option.label" >
                    </nz-option>
                  </nz-select>
                </div>
              </div>

              <button style="margin-left: 80px;" nz-button [nzSize]="'middle'" [nzType]="'primary'" (click)="getElevatorListss()">查询</button>
              <button style="margin-left: 20px;" nz-button [nzSize]="'middle'" [nzType]="'primary'" (click)="export()">导出</button>
            </div>
          </form>
        </nz-collapse>
        <nz-collapse [nzTitle]="'单位种子数据'" [nzActive]="flags" [nzDisabled]="false">
          <nz-table #nzTable [nzDataSource]="resultDate" [nzTotal]="total" [nzPageSize]="10"
                    [nzShowTotal]="true" [nzShowQuickJumper]="true" [nzBordered]="true" [nzSize]="'small'"
                    [nzIsPagination]="false">
            <thead nz-thead>
            <tr>
              <th nz-th>
                <span>注册代码</span>
              </th>
              <th nz-th>
                <span>安装地点</span>
              </th>
              <th nz-th>
                <span>使用单位</span>
              </th>
              <th nz-th>
                <span>维保单位</span>
              </th>
              <th nz-th>
                <span>场所</span>
              </th>
              <th nz-th>
                <span>梯型</span>
              </th>
            </tr>
            </thead>
            <tbody nz-tbody>
            <tr nz-tbody-tr *ngFor="let data of resultDate">
              <td nz-td>{{data.elevatorNum}}</td>
              <td nz-td>{{data.buildAddr}}</td>
              <td nz-td>{{data.usedPartyName}}</td>
              <td nz-td>{{data.maintenancePartyName}}</td>
              <td nz-td>{{data.elevatorPlace}}</td>
              <td nz-td>{{data.typeName}}</td>
            </tr>
            </tbody>
          </nz-table>
          <nz-pagination [nzPageIndex]="randomSelect.currentPage"  [nzTotal]="total" nzShowSizeChanger
                         (nzPageSizeChange)="nzPageSizeChange($event)"
                         (nzPageIndexClickChange)="nzPageIndexClickChange($event)" [nzPageSize]="randomSelect.pageSize"></nz-pagination>
        </nz-collapse>



        <nz-collapse [nzTitle]="'筛选后种子数据'" [nzActive]="flags" [nzDisabled]="false">
          <nz-table #nzTable [nzDataSource]="filterData"
                    [nzShowTotal]="true" [nzShowQuickJumper]="true" [nzBordered]="true" [nzSize]="'small'"
                    [nzIsPagination]="false">
            <thead nz-thead>
            <tr>
              <th nz-th>
                <span>编号</span>
              </th>
              <!--<th nz-th>
                <span>安装地点</span>
              </th>-->
              <th nz-th>
                <span>使用单位</span>
              </th>
              <th nz-th>
                <span>维保单位</span>
              </th>
            </tr>
            </thead>
            <tbody nz-tbody>
            <tr nz-tbody-tr *ngFor="let data of filterData">
              <td nz-td>{{data.usedPartyId}}</td>
              <!--<td nz-td>{{data.buildAddr}}</td>-->
              <td nz-td>{{data.usedPartyName}}</td>
              <td nz-td>{{data.maintenancePartyName}}</td>
            </tr>
            </tbody>
          </nz-table>
        </nz-collapse>
      </nz-collapseset>
    </nz-collapse>
  </nz-collapseset>

  <nz-collapseset>
    <nz-collapse [nzTitle]="'筛选负责人种子数据'" [nzActive]="false" [nzDisabled]="false">
      <nz-collapseset>
        <nz-collapse [nzTitle]="'选取条件'" [nzActive]="false" [nzDisabled]="false">
          <form nz-form [nzLayout]="'inline'">
            <div nz-form-item nz-col [nzSpan]="6">
              <div nz-form-label nz-col [nzSm]="6" [nzXs]="6">
                <label>单位</label>
              </div>
              <div nz-form-control nz-col [nzSm]="6" [nzXs]="6">
                <nz-select  style="width: 250px;" nzAllowClear [nzPlaceHolder]="'请选择'" [nzMode]="'multiple'" [(ngModel)]="unitParam"
                           [nzShowSearch]="true" name="unitParam">
                  <nz-option *ngFor="let option of unitList" [nzLabel]="option.partyName" [nzValue]="option.id" [nzDisabled]="option.disabled">
                  </nz-option>
                </nz-select>
              </div>
            </div>
            <div nz-form-item nz-col [nzSpan]="8">
              <div nz-form-label nz-col [nzSm]="6" [nzXs]="6">
                <label>用户类型</label>
              </div>
              <div nz-form-control>
                <nz-select nz-col [nzSm]="6" [nzXs]="6" style="width: 200px;" [nzPlaceHolder]="'请选择'" [nzMode]="'multiple'" [(ngModel)]="userType"
                           [nzShowSearch]="true" name="userType">
                  <nz-option [nzLabel]="'监察A类'" [nzValue]="'监察A类'">
                  </nz-option>
                  <nz-option [nzLabel]="'监察B类'" [nzValue]="'监察B类'">
                  </nz-option>
                  <nz-option [nzLabel]="'监察协管员证'" [nzValue]="'监察协管员证'">
                  </nz-option>
                  <nz-option [nzLabel]="'其他'" [nzValue]="'其他'">
                  </nz-option>
                </nz-select>
              </div>
            </div>
            <button nz-button [nzSize]="'middle'" [nzType]="'primary'" (click)="queryUnit()">查询</button>
          </form>
        </nz-collapse>
        <nz-collapse [nzTitle]="'负责人种子数据'" [nzActive]="userflags" [nzDisabled]="false">
          <nz-table #nzTable [nzDataSource]="checkUserList" [nzTotal]="checkUserListLength" [nzPageSize]="10"
                    [nzShowTotal]="true" [nzShowQuickJumper]="true" [nzBordered]="true" [nzSize]="'small'"
                    [nzIsPagination]="false">
            <thead nz-thead>
            <tr>
              <th nz-th>
                <span>编号</span>
              </th>
              <th nz-th>
                <span>姓名</span>
              </th>
              <th nz-th>
                <span>账号</span>
              </th>
              <th nz-th>
                <span>持证类型</span>
              </th>
              <th nz-th>
                <span>工号</span>
              </th>
              <th nz-th>
                <span>身份证号</span>
              </th>
              <th nz-th>
                <span>证书号码</span>
              </th>
            </tr>
            </thead>
            <tbody nz-tbody>
            <tr nz-tbody-tr *ngFor="let data of checkUserList">
              <td nz-td>{{data.id}}</td>
              <td nz-td>{{data.userName}}</td>
              <td nz-td>{{data.userCode}}</td>
              <td nz-td>{{data.cardType}}</td>
              <td nz-td>{{data.workNumber}}</td>
              <td nz-td>{{data.cardNumber}}</td>
              <td nz-td>{{data.typeNumber}}</td>
            </tr>
            </tbody>
          </nz-table>
        </nz-collapse>
      </nz-collapseset>
    </nz-collapse>
  </nz-collapseset>


  <nz-collapseset>
    <nz-collapse [nzTitle]="'双随机'" [nzActive]="false" [nzDisabled]="false">
      <div>
        <div style="float:left" class="container">
          <div class="left">
            <div style="text-align:left;margin-left:20px;font-weight:700;font-size:18px;">
              <p>种子数据共有：{{filterDataLength}} 条</p>
              <span>请设置抽选比例：</span>
              <nz-input style="width:40%" nzType="number" [nzPlaceHolder]="'请输入百分比(0-100)'" [(ngModel)]="partyPercent"
                        (ngModelChange)="partyperChange()"></nz-input><span> %</span>
              <p>将抽选出：{{partyselecttotal}} 条</p>
            </div>
            <h2>单位编号</h2>
            <div class="result-box">
              <p class="result-box1">{{resultbox1}}</p>
              <p class="result-box2">{{resultbox2}}</p>
              <p class="result-box3">{{resultbox3}}</p>
              <p class="result-box4">{{resultbox4}}</p>
              <p class="result-box5">{{resultbox5}}</p>
            </div>
            <button class="start" [ngClass]="{'start': startSel, 'end': endSel}" (click)="start()">{{buttonName}}</button>
          </div>
          <!--<div [innerHTML]="selectedList" class="list"></div>-->
        </div>

        <div style="float:right" class="container">
          <div class="left">
            <div style="text-align:left;margin-left:20px;font-weight:700;font-size:18px;">
              <p>种子数据共有：{{checkUserListLength}} 条</p>
              <span>请设置抽选比例：</span>
              <nz-input style="width:40%" nzType="number" [nzPlaceHolder]="'请输入百分比(0-100)'" [(ngModel)]="personPercent"
                        (ngModelChange)="personperChange()"></nz-input><span> %</span>
              <p>将抽选出：{{personselecttotal}} 条</p>
            </div>
            <h2>人员编号</h2>
            <div class="result-box">
              <p class="result-box1">{{presultbox1}}</p>
              <p class="result-box2">{{presultbox2}}</p>
              <p class="result-box3">{{presultbox3}}</p>
              <p class="result-box4">{{presultbox4}}</p>
              <p class="result-box5">{{presultbox5}}</p>
            </div>
            <button class="start" [ngClass]="{'start': pstartSel, 'end': pendSel}" (click)="startPerson()">{{pbuttonName}}</button>
          </div>
        </div>
      </div>


      <div style="clear:both">
        <div style="float:left;margin-top:20px;margin-bottom:40px;" class="container">
          <div class="left">
            <h3>已抽选名单</h3>
            <nz-table #nzTable [nzDataSource]="unitSelection" [nzTotal]="usertotal" [nzPageSize]="userPageSize"
                      [nzShowTotal]="true" [nzShowQuickJumper]="true" [nzBordered]="true" [nzSize]="'small'"
                      [nzIsPagination]="false">
              <thead nz-thead>
              <tr>
                <th nz-th>
                  <span>编号</span>
                </th>
                <th nz-th>
                  <span>单位名称</span>
                </th>
              </tr>
              </thead>
              <tbody nz-tbody>
              <tr nz-tbody-tr *ngFor="let data of unitSelection">
                <td nz-td>{{data.usedPartyId}}</td>
                <td nz-td>{{data.usedPartyName}}</td>
              </tr>
              </tbody>
            </nz-table>
          </div>
        </div>

        <div style="float:right;margin-top:20px;margin-bottom:40px;" class="container">
          <div class="left">
            <h3>已抽选名单</h3>
            <nz-table #nzTable [nzDataSource]="personSelected" [nzTotal]="usertotal" [nzPageSize]="userPageSize"
                      [nzShowTotal]="true" [nzShowQuickJumper]="true" [nzBordered]="true" [nzSize]="'small'"
                      [nzIsPagination]="false">
              <thead nz-thead>
              <tr>
                <th nz-th>
                  <span>编号</span>
                </th>
                <th nz-th>
                  <span>姓名</span>
                </th>
              </tr>
              </thead>
              <tbody nz-tbody>
              <tr nz-tbody-tr *ngFor="let data of personSelected">
                <td nz-td>{{data.id}}</td>
                <td nz-td>{{data.userName}}</td>
              </tr>
              </tbody>
            </nz-table>
          </div>
        </div>
      </div>


      <div style="clear:both"></div>
      <div style="margin-top:20px;padding:20px 0 20px 20px;clear:both;border: 1px solid #d9d9d9;border-radius: 10px">
        <h3 *ngIf="(!partyEnd)||(!userEnd)">正在抽取中......结束开始分配</h3>
        <h3 style="display: inline-block;" *ngIf="(partyEnd)&&(userEnd)">抽取完成，请开始随机分配负责人</h3>
        <button style="margin-left:20px;" *ngIf="(partyEnd)&&(userEnd)" nz-button [nzType]="'primary'" (click)="startDistribution()"
                nzGhost>
          <span>开始分配</span>
        </button>
      </div>

      <div *ngIf="(partyEnd)&&(userEnd)&&distribution.length>0" style="margin-top:10px;clear:both;padding:20px 0 20px 0px;clear:both;border: 1px solid #d9d9d9;border-radius: 10px">
        <h2 style="margin-left:20px;display: inline-block;">分配结果</h2>
        <button style="margin-left:20px;" *ngIf="(partyEnd)&&(userEnd)" nz-button [nzType]="'primary'" (click)="importSupervise(titleforget,contentforget,footerforget)"
                nzGhost>
          <span>保存至现场监督计划检查</span>
        </button>
        <!--<button style="margin-left:20px;" *ngIf="(partyEnd)&&(userEnd)" nz-button [nzType]="'primary'" (click)="exportDistribution()"
                nzGhost>
          <span>导出结果</span>
        </button>-->
        <nz-table #nzTable [nzDataSource]="distribution"  [nzPageSize]="10"
                  [nzShowTotal]="true" [nzShowQuickJumper]="true" [nzBordered]="true" [nzSize]="'small'"
                  [nzIsPagination]="false">
          <thead nz-thead>
          <tr>
            <th nz-th>
              <span>单位编号</span>
            </th>
            <th nz-th>
              <span>单位名称</span>
            </th>
            <th nz-th>
              <span>负责人</span>
            </th>
          </tr>
          </thead>
          <tbody nz-tbody>
          <tr nz-tbody-tr *ngFor="let data of distribution">
            <td nz-td>{{data.id}}</td>
            <td nz-td>{{data.name}}</td>
            <td nz-td>{{data.pname}}</td>
          </tr>
          </tbody>
        </nz-table>
      </div>


    </nz-collapse>
  </nz-collapseset>


  <!--保存至现场监督计划检查的添加框-->
  <ng-template #titleforget>
    <span>新增</span>
  </ng-template>
  <ng-template #contentforget>
    <form nz-form>
      <div nz-form-item nz-row>
        <div nz-form-label nz-col [nzSm]="4" [nzXs]="4">
          <label>计划名称</label>
        </div>
        <div nz-form-control nz-col [nzSm]="9" [nzXs]="9" nzHasFeedback >
          <nz-input nzDisabled name="planName" [(ngModel)]="planName"  [nzId]="'planName'" [nzSize]="'large'" ></nz-input>
        </div>

      </div>

      <div nz-form-item nz-row>
        <div nz-form-label nz-col [nzSpan]="4">
          <label nz-form-item-required >实施时间</label>
        </div>
        <div nz-form-control nz-col [nzSm]="18" [nzXs]="18" nzHasFeedback>
          <nz-datepicker  [nzSize]="'large'" [nzFormat]="'YYYY-MM-DD'" [(ngModel)]="beginTime"
                         name="beginTime" [nzPlaceHolder]="'开始日期'"></nz-datepicker>
          至
          <nz-datepicker  [nzSize]="'large'" [nzFormat]="'YYYY-MM-DD'" [(ngModel)]="endTime"
                         name="endTime" [nzPlaceHolder]="'结束日期'"></nz-datepicker>
        </div>
      </div>

      <div style="text-align: center;">
        <button nz-button (click)="saveData()" [nzSize]="'large'" [nzType]="'primary'">确定</button>
      </div>

    </form>
  </ng-template>
  <ng-template #footerforget>
    <div>
    </div>
  </ng-template>

  <ng-template #title>
    <span>机构详情</span>
  </ng-template>
  <ng-template #content>
    <party-modify-page [inValue]="partyData" [looktype]="true"></party-modify-page>
  </ng-template>
  <ng-template #footer>
    <div>
    </div>
  </ng-template>


  <nz-modal [nzVisible]="isVisible" [nzTitle]="'完成'" [nzContent]="modalContent" (nzOnCancel)="handleCancel($event)">
    <ng-template #modalContent>
      <p>您是否确定前去现场监督检查功能添加检查项。<span style="color: red" >(未添加检查项，将不能进行作业)</span></p>

      <div style="text-align: center;margin-top: 20px;">

        <button nz-button [nzType]="'default'" [nzSize]="'default'" (click)="handleCancel($event)">
          返 回
        </button>
        <button style="margin-left: 10px" nz-button [nzType]="'primary'" [nzSize]="'default'" (click)="handleOk($event)">
          确 定
        </button>
      </div>
    </ng-template>
  </nz-modal>
  <div class="form-fg " [ngStyle]="{'display':isShow === true ? 'block' : 'none' }" >
    <div class="thing">
      <div class="beam r1 r"></div>
      <div class="beam r3 r"></div>
      <div class="beam b1 b"></div>
      <div class="beam b3 b"></div>
    </div>
  </div>
</div>
